require_relative 'custom_const'

module Util
  include CustomConst

  def self.adjacent_line?(point, other)
    (point / LINE_LEN - other / LINE_LEN).abs.eql?(1)
  end

  def self.in_range?(point)
    CHESSMAN_RANGE.include?(point)
  end

  def self.king?(chessman)
    !soldier?(chessman)
  end

  def self.soldier?(chessman)
    (chessman & 0b10).zero?
  end

  def self.present?(chessman)
    !blank?(chessman)
  end

  def self.blank?(chessman)
    chessman.eql?(BLANK_CHESSMAN)
  end

  def self.player(chessman)
    chessman & 0b1
  end
end
